<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/tentime"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
   	
	<style type="text/css">
		.box-main {
		    margin: 0;
		    border: 0;
		    padding-top: 2px;
		    border-radius: 0;
		    box-shadow: none;
		}
		.box-main>.box-header {
		    /*border-bottom: 1px solid #eee;*/
		    /*padding: 13px 10px 1px 15px;*/
		    padding: 10px 10px 1px 5px;
		}
		.box-main>.box-header .box-title {
		    font-size: 16px;
		    /*margin-bottom: 13px;*/
		    float: left;
		}
		.box-main>.box-header .box-tools {
		    position: relative;
		    top: -6px;
		    right: 0;
		}
		.btn {
		    padding: 3px 8px;
		}
	</style>
</head>
<body>
	<div class="box-main" style="height: 40px;">
		<div class="box-header">
			<div class="box-title">
				<i class="fa fa-industry"></i> 公司管理
			</div>
			<div class="box-tools pull-right">
				<a href="#" class="btn btn-default" id="btnSearch" title="查询" data-click-binded="true"><i class="fa fa-filter"></i> 查询</a>
				<a href="#" class="btn btn-default" id="btnRefreshTree" title="刷新" data-click-binded="true"><i class="fa fa-refresh"></i> 刷新</a>
				<a href="#" class="btn btn-default" id="btnExpandTreeNode" title="展开一级" data-click-binded="true"><i class="fa fa-angle-double-down"></i> 展开</a>
				<a href="#" class="btn btn-default" id="btnCollapseTreeNode" title="折叠全部" data-click-binded="true"><i class="fa fa-angle-double-up"></i> 折叠</a>
				<a href="#" data-addtab="mailbox" class="btn btn-default btnTool" onclick="addTab();"><i class="fa fa-plus"></i> 新增</a>
				<!-- 
				<a href="/js/a/sys/company/form" class="btn btn-default btnTool" title="新增公司" data-click-binded="true"><i class="fa fa-plus"></i> 新增</a>
				 -->
				<a href="#" class="btn btn-default" id="btnSetting" title="设置" data-click-binded="true"><i class="fa fa-navicon"></i></a>
			</div>
		</div>
	</div>
	<div id="searchDiv">
		做账日期:
		<input id="startDate" name="startDate" type="text" maxlength="20" class="input-small Wdate" style="padding: 3px 4px;margin-bottom:0px;"
		 onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
		 至
		<input id="endDate" name="endDate" type="text" maxlength="20" class="input-small Wdate" style="padding: 3px 4px;margin-bottom:0px;"
		 onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:true});"/>
		 <button type="button" class="btn btn-small" onclick="customJQGridSearchDiv('searchDiv', 'dataGrid');"><i class="eap_zoom"></i>查询</button>
		 <button type="button" class="btn btn-small" onclick="customJQGridSearchDivReset('searchDiv', 'dataGrid');" style="margin: 0px!important;"><i class="eap_arrow_refresh_small"></i>重置</button>
	</div>
	
	<div style="margin:2px;">
	    <table id="dataGrid"></table>
	    <div id="dataGridPager"></div>
	</div>
	
	<script th:replace="/common/template :: common"></script>
	<script th:replace="/common/template :: jqgrid"></script>
	<script th:inline="javascript">
		$(document).ready(function() {
	    	$("#dataGrid").jqGrid({
	            url: ctx + "/buz/committee/listData",
	            datatype: "json",
	            styleUI: 'Bootstrap',
	            colModel:[
	                {name:'user_no',index:'user_no',label:'机构代号',frozen: true}
	                ,{name:'user_name',index:'user_name',label:'检测机构名称',width:120}
	                ,{name:'role_name',index:'role_name',label:'角色名称',width:120}
	                ,{name:'role_type',index:'role_type',label:'角色类型',width:120, stype: "select",searchoptions: {value:':全部;A角色:A角色;1:配送上门'}}
	                ,{name:'score',index:'score',label:'分数',width:150,formatter: "currency"
						,summaryTpl: "小计: {0}",summaryType: "sum",
						formatoptions: {thousandsSeparator:",",decimalSeparator:".",decimalPlaces:2}}
	                ,{name:'create_by_name',index:'create_by_name',label:'创建人',width:120}
	                ,{name:'create_date',index:'create_date',label:'创建时间'}
	            ],
	            rowNum:100,//初始化每页记录条数
	            rowList:[10,20,30,50,100,200,500,1000],//可选择的每页记录条数
	            pager: '#dataGridPager',//分页栏ID
	            mtype:'post',//数据请求方法
	            shrinkToFit:false,//是否适应容器宽度
	            viewrecords: true,//是否在分页栏中显示记录总条数
	            rownumbers:true,//是否显示行序号
	            jsonReader: {//json格式数据的reader
	                repeatitems:false//为true时将按照json属性的顺序填充数据到列中，为false时将按照colModel中配置的name属性获取，
	            },
	            toolbar:[false, 'top'],
	            hidegrid:false,//是否可以隐藏表格，如果为true则表头上会出现隐藏按钮
	            //caption:'送检单位委托信息',//表头文字
	            autowidth:true,//自动宽度
	            height:'100%',//高度，100%为根据行数自动调节高度
	            //height:"auto",//高度自适应
	            multiselect: true//是否可复选
	            ,grouping: true // 分组
                ,groupingView: {
                    groupField: ["role_type"],
                    groupColumnShow: [true],
                    groupText: ["<b>{0}</b>"],
                    groupSummary: [true],
                    groupCollapse: false
                }
	            ,footerrow : true//开放底部列
	            ,gridComplete: function() {
    	        	//页脚统计
    	        	var rowNum = parseInt($(this).getGridParam('records'), 10);
                    if (rowNum > 0) {
                    	$(".ui-jqgrid-sdiv").show();
	                    var score = $(this).getCol('score',false,'sum').toFixed(2);
						$(this).footerData('set', {'user_no':'合计：', 'score': score});
                    } else {
                    	$(".ui-jqgrid-sdiv").hide();
                    }
                }
	        }).navGrid("#dataGridPager",{edit:false,add:false,del:false,search:false}).jqGrid('filterToolbar',{searchOnEnter:false,stringResult:true});
	    	
	    	//$("#dataGrid").jqGrid('setFrozenColumns');//分组小计冻结有问题
	    	/*
            //添加按钮
            $("#dataGrid").addTopBtns([
                {
                    label:'新增',
                    icon:'eap_user_add',
                    handler:function(){
                    	showWin(title, win_width, win_height, url);
                    }
                },
                {
                    label:"修改",
                    icon:'eap_user_edit',
                    handler:function(row){
                        if(row && row.length == 1) {
                        	showWin(title, win_width, win_height, url + row[0].id);
                        } else {
                        	layer.msg('请选择一行记录再进行操作', {icon: 2});
                        }
                    }
                },
                {
                    label: '删除',
                    icon: 'eap_user_delete',
                    handler: function (row) {
                        if(row && row.length > 0){
                            var ids = [];
                            for(var i = 0;i < row.length; i++){
                                ids.push(row[i].id);
                            }
                            layer.confirm('确定要删除选中的数据吗？', {
                         		  btn: ['确定','取消'] //按钮
                         		}, function() {
                         			$.ajax({
	  									url : "${ctx}/cdlx/statis/delete",
	  									type:"post",
	  									data: {'ids' : ids},
	  									dataType:"json",
	  									traditional:true,
	  									success:function(data) {
	  										if(data.result > 0) {
	  											layer.msg('删除成功！', {icon: 1});
	  											$("#dataGrid").trigger("reloadGrid");
	  										} else {
	  											layer.msg('不删除失败！', {icon: 2});
	  										} 
	  									}
  								});
                         	});
                        }else{
                        	layer.msg('请选择一行记录再进行操作', {icon: 2});
                        }
                    }
                }
            ]);
	    	*/
            //$("#dataGrid").initSearchBar();
            //$("#dataGrid").customGridHeader();
            //$("#t_dataGrid").append($('#searchDiv').html());
	    	grid_resize('dataGrid');
            $("#btnSearch").on("click", function (e) {
                e.preventDefault();
                $("#searchDiv").toggle();
                //setTimeout("grid_resize('dataGrid')", 100);
                grid_resize('dataGrid');
            });
	    });
        
        function grid_resize(gridId) {
        	var height_iframe = $(window).outerHeight(true) - 13;
        	//console.log('*****height_iframe=' + height_iframe);
           	var height_box = $('.box-main').outerHeight(true);
        	//console.log('*****height_box=' + height_box);
           	var height_searchDiv = $('#searchDiv').outerHeight(true);
           	if($("#searchDiv").is(":hidden")) {//如果时候隐藏，高度应该为负数
           		height_searchDiv = 0;
           	}
        	//console.log('*****height_searchDiv=' + height_searchDiv);
        	/*
           	var height_title = $('#gview_'+gridId+' .ui-jqgrid-titlebar.ui-jqgrid-caption').outerHeight(true);
           	console.log('*****height_title=' + height_title);
        	 */
           	var height_btn = $('#gview_'+gridId+' .ui-userdata.ui-userdata-top').outerHeight(true);
        	//console.log('*****height_btn=' + height_btn);
           	var height_head = $('#gview_'+gridId+' .ui-jqgrid-hdiv').outerHeight(true);
        	//console.log('*****height_head=' + height_head);
           	var height_cal = $('#gview_'+gridId+' .ui-jqgrid-sdiv').outerHeight(true);
        	//console.log('*****height_cal=' + height_cal);
        	var height_pager = $('#'+gridId+'Pager').outerHeight(true);
        	//console.log('*****height_pager=' + height_pager);
           	var gridHeight = height_iframe-height_box/*-height_title*/-height_searchDiv-height_btn-height_head-height_cal-height_pager;
           	// console.log('最终表格高度******************************' + gridHeight);
           	$("#"+gridId).jqGrid("setGridHeight", gridHeight);
           	$("#"+gridId).jqGrid("setGridWidth", $(window).width()-10);
    	}
        /*
        window.onresize = function () {//执行
        	grid_resize('dataGrid');
        }
        */
        window.addEventListener('resize',function () {//执行
        	grid_resize('dataGrid');
        });
        //var ctx= [[@{/}]];
        function addTab() {
        	/* 启用新的tab
        	var id = Math.random().toString(36).substr(2);
        	top.$.addtabs.add({'id': id, 'url': '/saas/buz/committee/committeeForm', 'title': '新增'});
        	*/
        	
        	/**
             * 打开iframe窗口：title：窗口标题；width：窗口长度；height：窗口高度; reload:关闭是否刷新页面;dataGrid：需要刷新的表格
             */
             /*
             layui.use('layer', function() {
            	var layer = layui.layer;
	            var url = ctx + '/buz/committee/committeeForm';
	            var index = layer.open({
	                type: 2 //此处以iframe举例
	                ,title: '新增'
	                ,area: ['600px', '450px'] //宽高自适应
	                ,shade: 0.3
	                ,maxmin: true
	                ,content: url
	            });
             });
             */
             var url = ctx + '/buz/committee/committeeForm';
             openWin('新增委员', url, -1, -1);
             /*
             openWinMax('新增委员', url);
        	 openTab('新增委员', url);
             */
        }
        
        
        
	</script>
	   
</body>
</html>